# 切换到移动热点配置

Write-Host "=== 查找当前所有网络接口 ===" -ForegroundColor Cyan
ipconfig | Select-String "IPv4", "适配器"

Write-Host "`n=== 请找到移动热点的 IP 地址 ===" -ForegroundColor Yellow
Write-Host "通常在 '无线局域网适配器 本地连接*' 下" -ForegroundColor Yellow
Write-Host "例如: 192.168.137.1" -ForegroundColor Yellow
Write-Host ""

$hotspotIP = Read-Host "请输入移动热点的 IP 地址"

Write-Host "`n正在更新配置..." -ForegroundColor Green

# 更新前端配置
@"
VITE_API_URL=http://${hotspotIP}:3101
VITE_SOCKET_URL=http://${hotspotIP}:3101
"@ | Out-File -FilePath packages\web\.env -Encoding utf8

# 更新后端配置
@"
# 服务器端口
PORT=3101
# JWT密钥
JWT_SECRET=video-conf-secret-key-2024-random-abc123xyz
# 数据库
DB_PATH=./data/database.sqlite
# mediasoup配置 (端口范围)
MEDIASOUP_MIN_PORT=3102
MEDIASOUP_MAX_PORT=3110
MEDIASOUP_LISTEN_IP=0.0.0.0
MEDIASOUP_ANNOUNCED_IP=${hotspotIP}
# CORS允许来源
CORS_ORIGIN=http://localhost:3100,http://${hotspotIP}:3100
"@ | Out-File -FilePath packages\server\.env -Encoding utf8

Write-Host "`n✅ 配置已更新！" -ForegroundColor Green
Write-Host "`n现在请:" -ForegroundColor Yellow
Write-Host "1. 重启后端: npm run dev:server" -ForegroundColor White
Write-Host "2. 重启前端: npm run dev:web" -ForegroundColor White
Write-Host "3. 在另一台电脑访问: http://${hotspotIP}:3100" -ForegroundColor White

